package com.asset.dispoal.file.casedispose.service;

import com.asset.dispoal.file.casedispose.api.FileCaseService;
import com.asset.dispoal.file.casedispose.dto.FileCaseAddDispocalRequest;
import com.asset.dispoal.file.casedispose.dto.FileCaseBatchEditRequest;
import com.asset.dispoal.file.casedispose.dto.FileCaseConditionRequest;
import com.asset.dispoal.file.casedispose.dto.FileCaseExecutionRequest;
import com.asset.dispoal.file.casedispose.dto.FileCaseJudgmentRequest;
import com.asset.dispoal.file.casedispose.dto.FileCaseMediationRequest;
import com.asset.dispoal.file.casedispose.dto.FileCaseRegisterRequest;
import com.asset.dispoal.file.casedispose.service.command.FileCaseAddSingleFileCommand;
import com.asset.dispoal.file.casedispose.service.command.FileCaseBatchUpadteCommand;
import com.asset.dispoal.file.casedispose.service.command.FileCaseExecutionCommand;
import com.asset.dispoal.file.casedispose.service.command.FileCaseJudgmentCommand;
import com.asset.dispoal.file.casedispose.service.command.FileCaseMediationCommand;
import com.asset.dispoal.file.casedispose.service.command.FileCaseRegisterCommand;
import com.asset.dispoal.file.casedispose.strategy.FileUploadConditionStrategyManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tech.mhuang.pacebox.core.strategy.StrategyHandlerParam;
import tech.mhuang.pacebox.core.strategy.StrategyHandlerResult;
import tech.mhuang.pacebox.springboot.protocol.Result;

@Service
public class FileCaseServiceImpl implements FileCaseService {

    @Autowired
    FileCaseRegisterCommand fileCaseRegisterCommand;

    @Autowired
    FileCaseJudgmentCommand fileCaseJudgmentCommand;

    @Autowired
    FileCaseExecutionCommand fileCaseExecutionCommand;

    @Autowired
    FileCaseMediationCommand fileCaseMediationCommand;

    @Autowired
    FileCaseAddSingleFileCommand fileCaseAddSingleFileCommand;

    @Autowired
    FileUploadConditionStrategyManager fileUploadConditionStrategyManager;

    @Autowired
    private FileCaseBatchUpadteCommand fileCaseBatchUpadteCommand;

    @Override
    public Result register(FileCaseRegisterRequest request) {
        return fileCaseRegisterCommand.execute(request);
    }

    @Override
    public Result judgment(FileCaseJudgmentRequest request) {
        return fileCaseJudgmentCommand.execute(request);
    }

    @Override
    public Result execution(FileCaseExecutionRequest request) {
        return fileCaseExecutionCommand.execute(request);
    }

    @Override
    public Result mediation(FileCaseMediationRequest request) {
        return fileCaseMediationCommand.execute(request);
    }

    @Override
    public Result addSingleFile(FileCaseAddDispocalRequest request) {
        return fileCaseAddSingleFileCommand.execute(request);
    }

    @Override
    public Result condition(FileCaseConditionRequest request) {
        StrategyHandlerResult<Result> strategyHandlerResult = fileUploadConditionStrategyManager.strategy(new StrategyHandlerParam<>(request.getMode(), request));
        return strategyHandlerResult.getData();
    }

    @Override
    public Result batchEdit(FileCaseBatchEditRequest request) {
        return fileCaseBatchUpadteCommand.execute(request);
    }
}